import Vue from 'vue'
import Router from 'vue-router'
import App from './components/App.vue'
import {vote} from './filters'
import Channel from './components/views/Channel.vue'
import Detail from './components/views/Detail.vue'
import Feedback from './components/views/Feedback.vue'
import Follow from './components/views/Follow.vue'
import VoteView from './components/module/VoteView.vue'
import store from './store'

Vue.use(Router)

Vue.filter('vote', vote)

var router = new Router()

router.map({
    '/cid/:id/tid/:tid': {
        name: 'subject',
        component: Channel
    },
    '/cid/:id':{
        name: 'channel',
        component: Channel
    },
    '/detail/:id/cid/:cid/tid/:tid': {
        name: 'detail',
        component: Detail
    },
    'feedback': {
        name: 'feedback',
        component: Feedback
    },
    'follow': {
        name: 'follow',
        component: Follow
    }
})

router.beforeEach(function () {
    window.scrollTo(0, 0)
})

store.getNav().then(function (data) {
    router.start(App, '#app');

    router.redirect({
        '*': '/cid/' + data[0].i
    })
})

